package com.yunxi.module.system.mapper.dict;

import com.yunxi.framework.common.pojo.PageResult;
import com.yunxi.framework.mybatis.core.mapper.BaseMapperX;
import com.yunxi.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yunxi.module.system.model.dict.DictTypeDO;
import com.yunxi.module.system.vo.admin.dict.type.DictTypePageReqVO;
import org.apache.ibatis.annotations.Mapper;

/**
 * <p>
 * 字典类型 mapper
 * </p>
 *
 * @author lidy
 * @since 2024-05-08
 */
@Mapper
public interface DictTypeMapper extends BaseMapperX<DictTypeDO> {


    /**
     * 获得字典类型详情
     *
     * @param dictType 字典类型
     * @return 字典类型详情
     */
    default DictTypeDO selectByDictType(String dictType) {
        return selectOne(DictTypeDO::getType, dictType);
    }

    /**
     * 获得字典类型分页列表
     *
     * @param reqVO 查询条件
     * @return 字典类型分页列表
     */
    default PageResult<DictTypeDO> selectPage(DictTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DictTypeDO>()
                .likeIfPresent(DictTypeDO::getName, reqVO.getName())
                .likeIfPresent(DictTypeDO::getType, reqVO.getType())
                .eqIfPresent(DictTypeDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(DictTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DictTypeDO::getId));
    }
}
